package cn.iocoder.yudao.module.crm.dal.mysql.performance.person;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.performance.person.vo.PersonPerformanceConfigPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.performance.person.PersonPerformanceConfigDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * CRM_业绩配置 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface PersonPerformanceConfigMapper extends BaseMapperX<PersonPerformanceConfigDO> {

    default PageResult<PersonPerformanceConfigDO> selectPage(PersonPerformanceConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PersonPerformanceConfigDO>()
                .eqIfPresent(PersonPerformanceConfigDO::getYear, reqVO.getYear())
                .eqIfPresent(PersonPerformanceConfigDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PersonPerformanceConfigDO::getPerformancePoint, reqVO.getPerformancePoint())
                .orderByDesc(PersonPerformanceConfigDO::getYear)
                .orderByDesc(PersonPerformanceConfigDO::getUserId));
    }

    default List<PersonPerformanceConfigDO> selectList(PersonPerformanceConfigPageReqVO pageReqVO){
        return selectList(new LambdaQueryWrapperX<PersonPerformanceConfigDO>()
                .eqIfPresent(PersonPerformanceConfigDO::getYear, pageReqVO.getYear())
                .eqIfPresent(PersonPerformanceConfigDO::getUserId, pageReqVO.getUserId())
                .eqIfPresent(PersonPerformanceConfigDO::getPerformancePoint, pageReqVO.getPerformancePoint()));
    }
}